package com.skp.plastory;

import java.util.ArrayList;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class ListStory extends Activity {
	private ListView mListStory;
	private ListCustomAdapter listAdapter;
	private ArrayList<InfoStory> infoList = new ArrayList<InfoStory>();
	private ParsingJson json;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.list_story);

		mListStory = (ListView) findViewById(R.id.listView_story);
		json = new ParsingJson();
		infoList = json.parsingStory(getApplicationContext(), infoList);

		// infoList.add(new InfoStory("aaaa", "bbbb", "bbb", "ggg", "hhh"));
		// infoList.add(new InfoStory("aaaa", "bbbb", "bbb", "ggg", "hhh"));

		listAdapter = new ListCustomAdapter(this, R.layout.list_story_row, infoList);
		mListStory.setAdapter(listAdapter);

		mListStory.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
				Toast.makeText(getApplicationContext(), "NATE " + position, Toast.LENGTH_SHORT).show();
				Intent intent = new Intent(getApplicationContext(), ViewStory.class);
				
				intent.putExtra("date", infoList.get(position).getDate());
				intent.putExtra("title", infoList.get(position).getTitle());
				intent.putExtra("content", infoList.get(position).getContent());
				intent.putExtra("tag1", infoList.get(position).getTag1());
				intent.putExtra("tag2", infoList.get(position).getTag2());
				intent.putExtra("tag3", infoList.get(position).getTag3());
				
				startActivity(intent);

				//infoList.get(position).

			}
		});
	}
}